<style>
  #bookLove-cart {
    padding: 20px 25px 25px 0;
  }

  #bookLove-cart .layui-treeSelect .ztree li a, .ztree li span {
    margin: 0 0 2px 3px !important;
  }
</style>
<div class="layui-fluid" id="bookLove-cart">
  <form class="layui-form" action="" lay-filter="bookLove-cart-form">
    <input type="text" name="id" data-th-value="${bookLove.id}" autocomplete="off" hidden>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">图书名称：</label>
      <div class="layui-input-block">
        <input type="text" name="bookname" minlength="1" maxlength="20" lay-verify="required"
               autocomplete="off" class="layui-input" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">图书类型：</label>
      <div class="layui-input-block">
        <input type="text" name="type" lay-verify="required" autocomplete="off"
               class="layui-input" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">出版社：</label>
      <div class="layui-input-block">
        <input type="text" name="pubid" lay-verify="required"
               autocomplete="off" class="layui-input" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">书籍信息：</label>
      <div class="layui-input-block">
        <input type="text" name="message" lay-verify="required"
               autocomplete="off" class="layui-input" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">单价：</label>
      <div class="layui-input-block">
        <input type="text" name="bookmoney" autocomplete="off" class="layui-input"
               lay-verify="required|number" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">购买数量：</label>
      <div class="layui-input-block">
        <input type="text" name="number" autocomplete="off" class="layui-input"
               lay-verify="required|number" placeholder="请输入加入购物车的书籍数">
      </div>
    </div>
    <div class="layui-form-item febs-hide">
      <button class="layui-btn" lay-submit="" lay-filter="bookLove-cart-form-submit" id="submit"></button>
    </div>
  </form>
</div>
<script data-th-inline="javascript">
  layui.use(['febs', 'form', 'validate'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        bookLove = [[${bookLove}]],
        $view = $('#bookLove-cart'),
        validate = layui.validate;

    form.verify(validate);
    form.render();

    initbookLoveValue();

    function initbookLoveValue() {
      form.val("bookLove-cart-form", {
        "id": bookLove.id,
        "bookname": bookLove.bookname,
        "type": bookLove.type,
        "pubid": bookLove.pubid,
        "message": bookLove.message,
        "bookmoney": bookLove.bookmoney,
      });
    }

    form.on('submit(bookLove-cart-form-submit)', function (data) {
      console.log(data);
      console.log(123);
      if (febs.nativeEqual(data.field, bookLove)) {
        febs.alert.warn('订单未作任何修改！');
        return false;
      }
      febs.post(ctx + 'bookLove/cart', data.field, function () {
        layer.closeAll();
        febs.alert.success(bookCart.bookname + '，添加购物车成功');
        $('#febs-bookLove').find('#query').click();
      });
      return false;
    });
  });
</script>